package com.hx.portal.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.order.pojo.Content;
import com.hx.order.service.ContentService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/content")
@Api(description = "内容相关接口文档")
public class ContentController {

    @Reference
    private ContentService contentService;

    @GetMapping("/findAll")
    public List<Content> findAll(){
        return contentService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Content> findPage(int page, int size){
        return contentService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Content> findList(@RequestBody Map<String,Object> searchMap){
        return contentService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Content> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  contentService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Content findById(Integer id){
        return contentService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Content content){
        contentService.add(content);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Content content){
        contentService.update(content);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Integer id){
        contentService.delete(id);
        return new Result();
    }

}
